package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.model.FineClueCompanyModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.domain.dao.FineClueCompanyDao;
import com.xbongbong.pro.domain.entity.FineClueCompanyEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author mingliang
 * @Description 精线索公司
 **/
@Service("fineClueCompanyModel")
public class FineClueCompanyModelImpl implements FineClueCompanyModel {
    @Resource
    private FineClueCompanyDao fineClueCompanyDao;


    @Override
    public FineClueCompanyEntity getByCorpid(String corpid, Integer type) {
        return fineClueCompanyDao.getByCorpid(corpid, type);
    }

    @Override
    public Integer autoincrementRegisterCount(FineClueCompanyEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return fineClueCompanyDao.autoincrementRegisterCount(entity);
    }

    @Override
    public Integer save(FineClueCompanyEntity entity) throws XbbException {
        if (entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer insert(FineClueCompanyEntity entity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        entity.setDel(0);
        return fineClueCompanyDao.insert(entity);
    }

    @Override
    public Integer update(FineClueCompanyEntity entity) throws XbbException {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return fineClueCompanyDao.update(entity);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return fineClueCompanyDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return fineClueCompanyDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public List<String> getCorpidList() {
        return fineClueCompanyDao.getCorpidList();
    }

    @Override
    public List<String> getCorpidListWithType(int type) {
        return fineClueCompanyDao.getCorpidListWithType(type);
    }
}
